package com.andaily.domain.dto.account;

import com.andaily.domain.account.AccountOverviewShowType;
import com.andaily.domain.account.AccountOverviewSortType;
import com.andaily.domain.account.AccountStatisticsType;
import com.andaily.domain.dto.AbstractDTO;
import com.andaily.domain.user.AccountSetting;

import java.util.ArrayList;
import java.util.List;

/**
 * Account 在"更多..."中的选项有:
 * 1.每页显示的条目数, 默认30 ,10-100之间(用滑块)
 * 2.进入account overview的显示条件与排序规则,默认为显示所有与默认排序 (radio buttons)
 * 3.统计类型:  无;按周;按月;按年(若设置后由系统自动统计过去时间的数据,可从归档统计中查看到)
 * 4.查看已删除的账务信息(可恢复与彻底删除)
 * 5.导出数据(最后做)
 * 6.是否发送每月账务统计报表到用户注册的邮箱
 *
 * @author Shengzhao Li
 */
public class AccountSettingDTO extends AbstractDTO {

    private int prePageSize = 30;

    private AccountOverviewShowType showType = AccountOverviewShowType.ALL;
    private AccountOverviewSortType sortType = AccountOverviewSortType.DEFAULT;

    private AccountStatisticsType statisticsType = AccountStatisticsType.NONE;

    private boolean sendMonthStatisticsEmail = false;
    //removed account data
    private List<AccountDTO> deletedAccounts = new ArrayList<AccountDTO>();

    /**
     * Default constructor
     */
    public AccountSettingDTO() {
    }

    public AccountSettingDTO(AccountSetting accountSetting) {
        this.prePageSize = accountSetting.preAccountPageSize();
        this.sendMonthStatisticsEmail = accountSetting.sendMonthStatisticsEmail();
        this.showType = accountSetting.accountOverviewShowType();

        this.sortType = accountSetting.accountOverviewSortType();
        this.statisticsType = accountSetting.accountStatisticsType();
    }

    public int getDeletedAccountSize() {
        return deletedAccounts.size();
    }

    public boolean isSendMonthStatisticsEmail() {
        return sendMonthStatisticsEmail;
    }

    public void setSendMonthStatisticsEmail(boolean sendMonthStatisticsEmail) {
        this.sendMonthStatisticsEmail = sendMonthStatisticsEmail;
    }

    public int getPrePageSize() {
        return prePageSize;
    }

    public void setPrePageSize(int prePageSize) {
        this.prePageSize = prePageSize;
    }

    public AccountOverviewShowType getShowType() {
        return showType;
    }

    public void setShowType(AccountOverviewShowType showType) {
        this.showType = showType;
    }

    public AccountOverviewSortType getSortType() {
        return sortType;
    }

    public void setSortType(AccountOverviewSortType sortType) {
        this.sortType = sortType;
    }

    public AccountStatisticsType getStatisticsType() {
        return statisticsType;
    }

    public void setStatisticsType(AccountStatisticsType statisticsType) {
        this.statisticsType = statisticsType;
    }

    public List<AccountDTO> getDeletedAccounts() {
        return deletedAccounts;
    }

    public void setDeletedAccounts(List<AccountDTO> deletedAccounts) {
        this.deletedAccounts = deletedAccounts;
    }

    @Override
    public String toString() {
        return "AccountSettingDTO{" +
                "prePageSize=" + prePageSize +
                ", showType=" + showType +
                ", sortType=" + sortType +
                ", statisticsType=" + statisticsType +
                ", sendMonthStatisticsEmail=" + sendMonthStatisticsEmail +
                ", deletedAccounts=" + deletedAccounts +
                '}';
    }

    public AccountSetting toAccountSetting() {
        return new AccountSetting()
                .setPreAccountPageSize(this.prePageSize)
                .setAccountOverviewShowType(this.showType)
                .setAccountOverviewSortType(this.sortType)
                .setAccountStatisticsType(this.statisticsType)
                .setSendMonthStatisticsEmail(this.sendMonthStatisticsEmail);
    }
}
